package Logic.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;

/**
 * @author liujun
 * @version V1.0
 * @date 2022/2/27 4:33 PM
 * @author-Email ljfirst@mail.ustc.edu.cn
 * @description
 */
public class ReadFileTools {

    /**
     * @param URL    文件路径
     * @param symbol 根据 读取标识 获取该行数据
     * @return
     */
    public static List<int[][]> GetIntMatrixList(String URL, String symbol) {

        ArrayList<int[][]> list = new ArrayList<>();
        try {
            File file = new File(URL);
            BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
            String strLine = null;
            while (null != (strLine = bufferedReader.readLine())) {
                if (strLine.contains(symbol)) {
                    list.add(StringHandler.TransString2IntMatrix(strLine));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
}